package com.ruoyi.bussiness.controller;

import java.util.List;
import java.util.Map;

import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.bussiness.domain.CcyParseDetails;
import com.ruoyi.bussiness.service.ICcyParseDetailsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 数据回测Controller
 * 
 * @author wzy
 * @date 2025-10-19
 */
@RestController
@RequestMapping("/bussiness/details")
public class CcyParseDetailsController extends BaseController
{
    @Autowired
    private ICcyParseDetailsService ccyParseDetailsService;

    @PostMapping("/selectTotal")
    public Map<String,Object> selectTotal(@RequestBody CcyParseDetails criteria){
        return ccyParseDetailsService.selectTotal(criteria);
    }

    /**
     * 查询数据回测列表
     */
    @PreAuthorize("@ss.hasPermi('bussiness:details:list')")
    @GetMapping("/list")
    public TableDataInfo list(CcyParseDetails ccyParseDetails)
    {
        startPage();
        List<CcyParseDetails> list = ccyParseDetailsService.selectCcyParseDetailsList(ccyParseDetails);
        return getDataTable(list);
    }

    /**
     * 导出数据回测列表
     */
    @PreAuthorize("@ss.hasPermi('bussiness:details:export')")
    @Log(title = "数据回测", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CcyParseDetails ccyParseDetails)
    {
        List<CcyParseDetails> list = ccyParseDetailsService.selectCcyParseDetailsList(ccyParseDetails);
        ExcelUtil<CcyParseDetails> util = new ExcelUtil<CcyParseDetails>(CcyParseDetails.class);
        util.exportExcel(response, list, "数据回测数据");
    }

    /**
     * 获取数据回测详细信息
     */
    @PreAuthorize("@ss.hasPermi('bussiness:details:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(ccyParseDetailsService.selectCcyParseDetailsById(id));
    }

    /**
     * 新增数据回测
     */
    @PreAuthorize("@ss.hasPermi('bussiness:details:add')")
    @Log(title = "数据回测", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CcyParseDetails ccyParseDetails)
    {
        return toAjax(ccyParseDetailsService.insertCcyParseDetails(ccyParseDetails));
    }

    /**
     * 修改数据回测
     */
    @PreAuthorize("@ss.hasPermi('bussiness:details:edit')")
    @Log(title = "数据回测", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CcyParseDetails ccyParseDetails)
    {
        return toAjax(ccyParseDetailsService.updateCcyParseDetails(ccyParseDetails));
    }

    /**
     * 删除数据回测
     */
    @PreAuthorize("@ss.hasPermi('bussiness:details:remove')")
    @Log(title = "数据回测", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ccyParseDetailsService.deleteCcyParseDetailsByIds(ids));
    }
}
